---
sidebar_position: 2
tags: [grep]
---

# `filter`

Filter by path using **Regex** to match only the files that should be performed. <br />
By default, **Poku** searches for _`.test.`_ and `.spec.` files, but you can customize it using the `filter` option.

## CLI

```bash
# Default

npx poku --filter='.test.|.spec.' ./test
```

```bash
# Testing only a specific file

npx poku --filter='some-file' ./test
```

```bash
# Testing only specific files

npx poku --filter='some-file|other-file' ./test
```

```bash
# Testing only paths that contains "unit"

npx poku --filter='unit' ./test
```

```bash
# Testing only paths that contains "unit" by using Poku as a NPM script

npm run tests -- --filter='unit'
```

### Environment Variable

By using `FILTER` from **Environment Variable**, it will overwrite the `filter` option.

```bash
# Testing only a specific file

FILTER='some-file' npx poku ./test
```

```bash
# Testing only specific files

FILTER='some-file|other-file' npx poku ./test
```

```bash
# Testing only paths that contains "unit"

FILTER='unit' npx poku ./test
```

```bash
# Testing only paths that contains "unit" by using Poku as a NPM script

FILTER='unit' npm run tests
```

## API

```ts
/**
 * @default
 *
 * Testing all `*.test.*` files.
 */

await poku('./test', {
  filter: /\.test\./,
});
```

```ts
/**
 * Testing all `ts`, `js`, `mts` and `mjs` files
 */

await poku('./test', {
  filter: /\.(m)?(j|t)s$/,
  // filter: /\.(js|ts|mjs|mts)$/,
});
```
